/*
 * Generated file. 
 * 
 * Mobile_005flargeContent.java
 */
package xsp;

import com.ibm.xsp.page.compiled.AbstractCompiledPage;
import com.ibm.xsp.page.compiled.AbstractCompiledPageDispatcher;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import com.ibm.xsp.page.compiled.NoSuchComponentException;
import com.ibm.xsp.page.compiled.PageExpressionEvaluator;
import java.lang.String;
import com.ibm.xsp.component.UIViewRootEx2;
import com.ibm.xsp.component.UIPanelEx;
import com.ibm.xsp.model.domino.DominoDocumentData;
import javax.faces.el.MethodBinding;
import com.ibm.xsp.component.xp.XspDiv;
import com.ibm.xsp.component.xp.XspOutputText;
import java.lang.Object;
import javax.faces.el.ValueBinding;
import com.ibm.xsp.component.xp.XspCommandButton;
import com.ibm.xsp.component.xp.XspEventHandler;
import com.ibm.xsp.extlib.actions.MoveToAction;

@SuppressWarnings("all")
public class Mobile_005flargeContent extends AbstractCompiledPageDispatcher{
    
    public Mobile_005flargeContent() {
        super("3.0");
    }

    protected AbstractCompiledPage createPage(int pageIndex) {
        return new Mobile_005flargeContentPage();
    }
    
    protected boolean isCustomControl() {
        return true;
    }

    public static class Mobile_005flargeContentPage extends AbstractCompiledPage {
        
        private static final ComponentInfo[] s_infos = new ComponentInfo[]{
            ComponentInfo.EMPTY_NORMAL, // 0 "computedfield1"
            new ComponentInfo(false, new int[]{0}), // 1 "divcontent"
            ComponentInfo.EMPTY_NORMAL, // 2 eventHandler
            new ComponentInfo(false, new int[]{2}), // 3 "button2"
            new ComponentInfo(false, new int[]{3}), // 4 "panel16"
            new ComponentInfo(false, new int[]{1, 4}), // 5 panel
            new ComponentInfo(false, new int[]{5}), // 6 view
        };
        
        public Mobile_005flargeContentPage() {
            super(6, s_infos );
        }
        
        public int getComponentForId(String id) throws NoSuchComponentException { 
            if( "divcontent".equals(id) )
                return 1;
            if( "computedfield1".equals(id) )
                return 0;
            if( "panel16".equals(id) )
                return 4;
            if( "button2".equals(id) )
                return 3;
            return -1;
        }
        
        public UIComponent createComponent(int id, FacesContext context,
                UIComponent parent, PageExpressionEvaluator evaluator)
                throws NoSuchComponentException { 
            switch (id) {
            case 6:
                return createView(context, parent, evaluator);
            case 5:
                return createPanel(context, parent, evaluator);
            case 1:
                return createDivcontent(context, parent, evaluator);
            case 0:
                return createComputedfield1(context, parent, evaluator);
            case 4:
                return createPanel16(context, parent, evaluator);
            case 3:
                return createButton2(context, parent, evaluator);
            case 2:
                return createEventHandler(context, parent, evaluator);
            }
            throw new NoSuchComponentException(id);
        }
        
        private UIComponent createView(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIViewRootEx2 result = new UIViewRootEx2();
            initViewRoot(result);
            return result;
        }

        private UIComponent createPanel(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIPanelEx result = new UIPanelEx();
            DominoDocumentData data = new DominoDocumentData();
            data.setComponent(result);
            data.setComputeWithForm("onsave");
            String sourceId = "/xp:view[1]/xp:panel[1]/xp:this.data[1]/xp:dominoDocument[1]/xp:this.postOpenDocument[1]/text()";
            MethodBinding postOpenDocument = evaluator.createMethodBinding(result,
                    "#{javascript:// get the main topic details...\n\t\t\t\t\tviewScope.mainUNID = dominoDoc.getItemValueString(\"mainID\");\n\t\t\t\t\tif(null != viewScope.mainUNID){\n\t\t\t\t\t\tvar mainTopic:NotesDocument = null;\n\t\t\t\t\t\ttry{\n\t\t\t\t\t\t\t// try to locate parent topic...\n\t\t\t\t\t\t\tmainTopic = database.getDocumentByUNID(viewScope.mainUNID);\n\t\t\t\t\t\t\tif(null != mainTopic){\n\t\t\t\t\t\t\t\tviewScope.mainID = mainTopic.getNoteID();\n\t\t\t\t\t\t\t\tviewScope.mainSubject = mainTopic.getItemValueString(\"Subject\");\n\t\t\t\t\t\t\t\tviewScope.mainCreated = mainTopic.getCreated().toJavaDate();\n\t\t\t\t\t\t\t\tviewScope.mainFrom = mainTopic.getItemValueString(\"From\");\n\t\t\t\t\t\t\t\tviewScope.mainAbstract = mainTopic.getItemValueString(\"Abstract\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}catch(e){\n\t\t\t\t\t\t\t// if non-existent, then use current document...\n\t\t\t\t\t\t\tmainTopic = dominoDoc;\n\t\t\t\t\t\t\tif(null != mainTopic){\n\t\t\t\t\t\t\t\tviewScope.mainID = mainTopic.getNoteID();\n\t\t\t\t\t\t\t\tviewScope.mainSubject = mainTopic.getItemValueString(\"Subject\");\n\t\t\t\t\t\t\t\tviewScope.mainCreated = mainTopic.getDocument().getCreated().toJavaDate();\n\t\t\t\t\t\t\t\tviewScope.mainFrom = mainTopic.getItemValueString(\"From\");\n\t\t\t\t\t\t\t\tviewScope.mainAbstract = mainTopic.getItemValueString(\"Abstract\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}",
                    null,null, sourceId);
            data.setPostOpenDocument(postOpenDocument);
            data.setAction("openDocument");
            data.setVar("dominoDoc");
            data.setFormName("MainTopic");
            result.addData(data);
            return result;
        }

        private UIComponent createDivcontent(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspDiv result = new XspDiv();
            setId(result, "divContent");
            return result;
        }

        private UIComponent createComputedfield1(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspOutputText result = new XspOutputText();
            String sourceId = "computedField1/xp:this.value[1]/text()";
            String valueExpr = "#{dominoDoc.body}";
            ValueBinding value = evaluator.createValueBinding(result, valueExpr, sourceId,Object.class);
            result.setValueBinding("value", value);
            result.setEscape(false);
            result.setRendered(true);
            setId(result, "computedField1");
            return result;
        }

        private UIComponent createPanel16(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIPanelEx result = new UIPanelEx();
            result.setStyleClass("xlFormFooterContainer");
            setId(result, "panel16");
            return result;
        }

        private UIComponent createButton2(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspCommandButton result = new XspCommandButton();
            result.setValue("Back");
            result.setStyleClass("xlFormFooterButton");
            setId(result, "button2");
            return result;
        }

        private UIComponent createEventHandler(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspEventHandler result = new XspEventHandler();
            MoveToAction action = new MoveToAction();
            action.setComponent(result);
            String sourceId = "button2/xp:eventHandler[1]/xp:this.action[1]/xe:moveTo[1]/xp:this.targetPage[1]/text()";
            String targetPageExpr = "#{javascript:\n\t\t\t\t\t\t\t\t\tvar url = \"document\" + sessionScope.backURL;\n\t\t\t\t\t\t\t\t\treturn url;\n\t\t\t\t\t\t\t\t}";
            ValueBinding targetPage = evaluator.createValueBinding(result, targetPageExpr, sourceId,String.class);
            action.setValueBinding("targetPage", targetPage);
            action.setForceFullRefresh(true);
            action.setTransitionType("slide");
            action.setDirection("Right to Left");
            action.setSourceReferenceId("button2/xp:eventHandler[1]/xp:this.action[1]/xe:moveTo[1]");
            result.setAction(action);
            result.setSubmit(true);
            result.setEvent("onclick");
            result.setRefreshMode("complete");
            return result;
        }

    }
}
